﻿using System;
using System.Collections.Generic;
using ShopB2C.Enums;

namespace ShopB2C.Parameters {
    // ModuleKey - 商品 id - 排序字段 - 页码 - 评分
    // Product-32-1-1-0
    /// <summary>
    /// 商品评论参数组合
    /// </summary>
    [Serializable]
    public class CommentParam {
        public CommentParam() {
            this.ProductId = 0;
            this.SortFieldName = CommentSortFieldNames.Newest;
            this.GradeValue = CommentGradeValues.All;
            this.PageIndex = 1;
        }
        /// <summary>
        /// 商品 id
        /// </summary>
        public int ProductId { get; set; }
        /// <summary>
        /// 排序字段
        /// </summary>
        public CommentSortFieldNames SortFieldName { get; set; }
        /// <summary>
        /// 评分
        /// </summary>
        public CommentGradeValues GradeValue { get; set; }
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 参选还原成字符串
        /// </summary>
        /// <returns>string</returns>
        public override string ToString() {
            return string.Format("{0}-{1}-{2}-{3}",
                this.ProductId,
                (int)this.SortFieldName,
                this.PageIndex,
                (int)this.GradeValue
                );
        }
        /// <summary>
        /// 克隆一个参数类
        /// </summary>
        /// <returns>克隆的参数类</returns>
        public CommentParam Clone() {
            return new CommentParam() {
                ProductId = this.ProductId,
                SortFieldName = this.SortFieldName,
                GradeValue = this.GradeValue,
                PageIndex = this.PageIndex
            };
        }
    }
}
